package com.itheima.controller;

import com.itheima.domain.Book;
import com.itheima.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class BookView {
    @Autowired
    private BookService bookService;
    @GetMapping("/change/book")
    public ModelAndView changeBook(@RequestParam("id") Integer id) {

        ModelAndView modelAndView = new ModelAndView("changebook");
        Book byId = bookService.findBookById(id);
        System.out.println("查后的id="+byId.getId());
        modelAndView.addObject("book", byId);
        return modelAndView;
    }
}
